package cn.gson.crm.control.source;

import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import cn.gson.crm.control.base.BaseServlet;
import cn.gson.crm.model.dao.SourceDao;

/**
 * Servlet implementation class AddsourceServlet
 */
@WebServlet("/addsource")
public class AddsourceServlet extends BaseServlet {
	private static final long serialVersionUID = 1L;
	private SourceDao sd=new SourceDao();
       
	@Override
	protected void post(HttpServletRequest request, HttpServletResponse response) throws Exception {
		String sourceName=request.getParameter("SourceName");
		if(sourceName!=null&&!sourceName.isEmpty()){
			if (sd.addSource(sourceName)) {
				redirect("source");
			}
		}else {
			request.setAttribute("error", "来源不能为空");
			redirect("source");
		}
	}
}

